<?php
class Category extends Ecore_Db {
	public function get($intId) {
		try {	
			$this->prepare('call categories_get(?)');		
			$this->bindParam(1, $intId, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();			
			return isset($arrResult[0]) ? $arrResult[0] : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Category::get - ' .$e->getMessage());	
		}
	}
	public function getParent($intType) {
		try {	
			$this->prepare('call categories_getall_parent(?)');		
			$this->bindParam(1, $intType, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();			
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Category::getParent - ' .$e->getMessage());	
		}
	}
	public function getChild($intParentId) {
		try {	
			$this->prepare('call categories_getall_child(?)');		
			$this->bindParam(1, $intParentId, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();			
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Category::getChild - ' .$e->getMessage());	
		}
	}
	public function getTag($intType, $intAdv=0, $intLimit=0) {
		try {	
			$this->prepare('call categories_tag(?,?,?)');		
			$this->bindParam(1, $intType	, PDO::PARAM_INT, 6);
			$this->bindParam(2, $intAdv		, PDO::PARAM_INT, 4);
			$this->bindParam(3, $intLimit	, PDO::PARAM_INT, 6);
			$arrResult 	= $this->fetchAll();			
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Category::getTag - ' .$e->getMessage());	
		}
	}
}